OBJECT Table 370 Excel Buffer
{
  OBJECT-PROPERTIES
  {
    Date=17/06/15;
    Time=07:09:04;
    Modified=Yes;
    Version List=NAVW17.10.00.36078,ADC1.00;
  }
  PROPERTIES
  {
    CaptionML=[ENU=Excel Buffer;
               ENG=Excel Buffer];
  }
  FIELDS
  {
    { 1   ;   ;Row No.             ;Integer       ;OnValidate=BEGIN
                                                                xlRowID := '';
                                                                IF "Row No." <> 0 THEN
                                                                  xlRowID := FORMAT("Row No.");
                                                              END;

                                                   CaptionML=[ENU=Row No.;
                                                              ENG=Row No.] }
    { 2   ;   ;xlRowID             ;Text10        ;CaptionML=[ENU=xlRowID;
                                                              ENG=xlRowID] }
    { 3   ;   ;Column No.          ;Integer       ;OnValidate=VAR
                                                                x@1000 : Integer;
                                                                i@1001 : Integer;
                                                                y@1003 : Integer;
                                                                c@1002 : Char;
                                                                t@1102601000 : Text[30];
                                                              BEGIN
                                                                xlColID := '';
                                                                x := "Column No.";
                                                                WHILE x > 26 DO BEGIN
                                                                  y := x MOD 26;
                                                                  IF y = 0 THEN
                                                                    y := 26;
                                                                  c := 64 + y;
                                                                  i := i + 1;
                                                                  t[i] := c;
                                                                  x := (x - y) DIV 26;
                                                                END;
                                                                IF x > 0 THEN BEGIN
                                                                  c := 64 + x;
                                                                  i := i + 1;
                                                                  t[i] := c;
                                                                END;
                                                                FOR x := 1 TO i DO
                                                                  xlColID[x] := t[1 + i - x];
                                                              END;

                                                   CaptionML=[ENU=Column No.;
                                                              ENG=Column No.] }
    { 4   ;   ;xlColID             ;Text10        ;CaptionML=[ENU=xlColID;
                                                              ENG=xlColID] }
    { 5   ;   ;Cell Value as Text  ;Text250       ;CaptionML=[ENU=Cell Value as Text;
                                                              ENG=Cell Value as Text] }
    { 6   ;   ;Comment             ;Text250       ;CaptionML=[ENU=Comment;
                                                              ENG=Comment] }
    { 7   ;   ;Formula             ;Text250       ;CaptionML=[ENU=Formula;
                                                              ENG=Formula] }
    { 8   ;   ;Bold                ;Boolean       ;CaptionML=[ENU=Bold;
                                                              ENG=Bold] }
    { 9   ;   ;Italic              ;Boolean       ;CaptionML=[ENU=Italic;
                                                              ENG=Italic] }
    { 10  ;   ;Underline           ;Boolean       ;CaptionML=[ENU=Underline;
                                                              ENG=Underline] }
    { 11  ;   ;NumberFormat        ;Text30        ;CaptionML=[ENU=NumberFormat;
                                                              ENG=NumberFormat] }
    { 12  ;   ;Formula2            ;Text250       ;CaptionML=[ENU=Formula2;
                                                              ENG=Formula2] }
    { 13  ;   ;Formula3            ;Text250       ;CaptionML=[ENU=Formula3;
                                                              ENG=Formula3] }
    { 14  ;   ;Formula4            ;Text250       ;CaptionML=[ENU=Formula4;
                                                              ENG=Formula4] }
    { 15  ;   ;Cell Type           ;Option        ;CaptionML=[ENU=Cell Type;
                                                              ENG=Cell Type];
                                                   OptionCaptionML=[ENU=Number,Text,Date,Time;
                                                                    ENG=Number,Text,Date,Time];
                                                   OptionString=Number,Text,Date,Time }
  }
  KEYS
  {
    {    ;Row No.,Column No.                      ;Clustered=Yes }
  }
  FIELDGROUPS
  {
  }
  CODE
  {
    VAR
      Text000@1000 : TextConst '@@@="{Locked=""Excel""}";ENU=Excel not found.;ENG=Excel not found.';
      Text001@1001 : TextConst 'ENU=You must enter a file name.;ENG=You must enter a file name.';
      Text002@1002 : TextConst '@@@="{Locked=""Excel""}";ENU=You must enter an Excel worksheet name.;ENG=You must enter an Excel worksheet name.';
      Text003@1003 : TextConst 'ENU=The file %1 does not exist.;ENG=The file %1 does not exist.';
      Text004@1004 : TextConst '@@@="{Locked=""Excel""}";ENU=The Excel worksheet %1 does not exist.;ENG=The Excel worksheet %1 does not exist.';
      Text005@1005 : TextConst '@@@="{Locked=""Excel""}";ENU=Creating Excel worksheet...\\;ENG=Creating Excel worksheet...\\';
      Text006@1006 : TextConst 'ENU=%1%3%4%3Page %2;ENG=%1%3%4%3Page %2';
      Text007@1007 : TextConst '@@@="{Locked=""Excel""}";ENU=Reading Excel worksheet...\\;ENG=Reading Excel worksheet...\\';
      Text013@1013 : TextConst 'ENU=&B;ENG=&B';
      Text014@1014 : TextConst 'ENU=&D;ENG=&D';
      Text015@1015 : TextConst 'ENU=&P;ENG=&P';
      Text016@1016 : TextConst 'ENU=A1;ENG=A1';
      Text017@1017 : TextConst 'ENU=SUMIF;ENG=SUMIF';
      Text018@1018 : TextConst 'ENU=#N/A;ENG=#N/A';
      Text019@1019 : TextConst '@@@={Locked} Used to define an Excel range name. You must refer to Excel rules to change this term.;ENU=GLAcc;ENG=GLAcc';
      Text020@1020 : TextConst '@@@={Locked} Used to define an Excel range name. You must refer to Excel rules to change this term.;ENU=Period;ENG=Period';
      Text021@1021 : TextConst 'ENU=Budget;ENG=Budget';
      InfoExcelBuf@1036 : TEMPORARY Record 370;
      FileManagement@1045 : Codeunit 419;
      XlWrkBkWriter@1022 : DotNet "'Microsoft.Dynamics.Nav.OpenXml, Version=7.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.Microsoft.Dynamics.Nav.OpenXml.Spreadsheet.WorkbookWriter";
      XlWrkBkReader@1023 : DotNet "'Microsoft.Dynamics.Nav.OpenXml, Version=7.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.Microsoft.Dynamics.Nav.OpenXml.Spreadsheet.WorkbookReader";
      XlWrkShtWriter@1024 : DotNet "'Microsoft.Dynamics.Nav.OpenXml, Version=7.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.Microsoft.Dynamics.Nav.OpenXml.Spreadsheet.WorksheetWriter";
      XlWrkShtReader@1043 : DotNet "'Microsoft.Dynamics.Nav.OpenXml, Version=7.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.Microsoft.Dynamics.Nav.OpenXml.Spreadsheet.WorksheetReader";
      XlApp@1044 : DotNet "'Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'.Microsoft.Office.Interop.Excel.ApplicationClass" RUNONCLIENT;
      XlWrkBk@1051 : DotNet "'Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'.Microsoft.Office.Interop.Excel.Workbook" RUNONCLIENT;
      XlWrkSht@1009 : DotNet "'Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'.Microsoft.Office.Interop.Excel.Worksheet" RUNONCLIENT;
      XlHelper@1052 : DotNet "'Microsoft.Dynamics.Nav.Integration.Office, Version=7.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.Microsoft.Dynamics.Nav.Integration.Office.Excel.ExcelHelper" RUNONCLIENT;
      ActiveSheetName@1049 : Text[250];
      RangeStartXlRow@1034 : Text[30];
      RangeStartXlCol@1033 : Text[30];
      RangeEndXlRow@1032 : Text[30];
      RangeEndXlCol@1031 : Text[30];
      FileNameServer@1046 : Text;
      FriendlyName@1025 : Text;
      CurrentRow@1029 : Integer;
      CurrentCol@1030 : Integer;
      UseInfoSheet@1035 : Boolean;
      Text022@1041 : TextConst '@@@={Locked} Used to define an Excel range name. You must refer to Excel rules to change this term.;ENU=CostAcc;ENG=CostAcc';
      Text023@1037 : TextConst 'ENU=Information;ENG=Information';
      Text034@1039 : TextConst '@@@="{Split=r''\|\*\..{1,4}\|?''}{Locked=""Excel""}";ENU=Excel Files (*.xls*)|*.xls*|All Files (*.*)|*.*;ENG=Excel Files (*.xls*)|*.xls*|All Files (*.*)|*.*';
      Text035@1040 : TextConst 'ENU=The operation was canceled.;ENG=The operation was cancelled.';
      Text036@1042 : TextConst '@@@="{Locked=""Excel""}";ENU=The Excel workbook does not exist.;ENG=The Excel workbook does not exist.';
      Text037@1047 : TextConst '@@@="{Locked=""Excel""}";ENU=Could not create the Excel workbook.;ENG=Could not create the Excel workbook.';
      Text038@1048 : TextConst 'ENU=Global variable %1 is not included for test.;ENG=Global variable %1 is not included for test.';
      Text039@1050 : TextConst 'ENU=Cell type has not been set.;ENG=Cell type has not been set.';
      Text040@1008 : TextConst '@@@="{Locked=""Excel""}";ENU=Export Excel File;ENG=Export Excel File';
      SavingDocumentMsg@1010 : TextConst 'ENU=Saving the following document: %1.;ENG=Saving the following document: %1.';
      SelectWorksheetMsg@1011 : TextConst '@@@="{Locked=""Microsoft Excel""}";ENU=Choose the Microsoft Excel worksheet.;ENG=Choose the Microsoft Excel worksheet.';
      ExcelFileExtensionTok@1012 : TextConst '@@@={Locked};ENU=.xlsx;ENG=.xlsx';
      SheetBadChars@1000000000 : TextConst 'ENU=.?!*\/[]'':';
      RowOffSet@1000000001 : Integer;

    PROCEDURE CreateBook@1(SheetName@1000 : Text[250]);
    BEGIN
      IF SheetName = '' THEN
        ERROR(Text002);

      FileNameServer := FileManagement.ServerTempFileName('xlsx');
      XlWrkBkWriter := XlWrkBkWriter.Create(FileNameServer);
      IF ISNULL(XlWrkBkWriter) THEN
        ERROR(Text037);

      XlWrkShtWriter := XlWrkBkWriter.FirstWorksheet;
      IF SheetName <> '' THEN BEGIN
        XlWrkShtWriter.Name := SheetName;
        ActiveSheetName := SheetName;
      END
    END;

    PROCEDURE OpenBook@2(FileName@1000 : Text;SheetName@1001 : Text[250]);
    BEGIN
      IF FileName = '' THEN
        ERROR(Text001);

      IF SheetName = '' THEN
        ERROR(Text002);

      XlWrkBkReader := XlWrkBkReader.Open(FileName);
      IF XlWrkBkReader.HasWorksheet(SheetName) THEN BEGIN
        XlWrkShtReader := XlWrkBkReader.GetWorksheetByName(SheetName);
      END ELSE BEGIN
        QuitExcel;
        ERROR(Text004,SheetName);
      END;
    END;

    PROCEDURE UpdateBook@5(FileName@1000 : Text;SheetName@1001 : Text[250]);
    BEGIN
      IF FileName = '' THEN
        ERROR(Text001);

      IF SheetName = '' THEN
        ERROR(Text002);

      FileNameServer := FileName;
      XlWrkBkWriter := XlWrkBkWriter.Open(FileNameServer);
      IF XlWrkBkWriter.HasWorksheet(SheetName) THEN BEGIN
        XlWrkShtWriter := XlWrkBkWriter.GetWorksheetByName(SheetName);
        ActiveSheetName := SheetName;
      END ELSE BEGIN
        QuitExcel;
        ERROR(Text004,SheetName);
      END;
    END;

    PROCEDURE CloseBook@30();
    BEGIN
      IF NOT ISNULL(XlWrkBkWriter) THEN BEGIN
        XlWrkBkWriter.ClearFormulaCalculations;
        XlWrkBkWriter.ValidateDocument;
        XlWrkBkWriter.Close;
        CLEAR(XlWrkShtWriter);
        CLEAR(XlWrkBkWriter);
      END;

      IF NOT ISNULL(XlWrkBkReader) THEN BEGIN
        CLEAR(XlWrkShtReader);
        CLEAR(XlWrkBkReader);
      END;
    END;

    PROCEDURE WriteSheet@37(ReportHeader@1001 : Text[80];CompanyName@1002 : Text[30];UserID2@1003 : Text);
    VAR
      ExcelBufferDialogMgt@1009 : Codeunit 5370;
      OrientationValues@1000 : DotNet "'DocumentFormat.OpenXml, Version=2.5.5631.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.DocumentFormat.OpenXml.Spreadsheet.OrientationValues";
      CRLF@1008 : Char;
      RecNo@1010 : Integer;
      InfoRecNo@1012 : Integer;
      TotalRecNo@1011 : Integer;
      LastUpdate@1004 : DateTime;
    BEGIN
      LastUpdate := CURRENTDATETIME;
      ExcelBufferDialogMgt.Open(Text005);

      CRLF := 10;
      RecNo := 1;
      TotalRecNo := COUNT + InfoExcelBuf.COUNT;
      RecNo := 0;

      //ADC1.00 Clear the Variable
      RowOffSet := 0;

      XlWrkShtWriter.AddPageSetup(OrientationValues.Landscape);

      // commit is required because of the result boolean check of ExcelBufferDialogMgt.RUN
      COMMIT;

      IF FINDSET THEN
        REPEAT
          RecNo := RecNo + 1;
          IF NOT UpdateProgressDialog(ExcelBufferDialogMgt,LastUpdate,RecNo,TotalRecNo) THEN BEGIN
            QuitExcel;
            ERROR(Text035)
          END;

          //ADC1.00 >>
          //Is this a New Worksheet, if it is add it
          IF ("Column No." = 0) AND ("Cell Value as Text" <> '') THEN
            AddNewWorksheet;
          //ADC1.00 <<

          //ADC1.00 Change the "Row No." to the Sheet "Row No."
          "Row No." := "Row No." - RowOffSet;

          //ADC1.00 If this is not a New Worksheet Write the Cell
          IF "Column No." > 0 THEN

            IF Formula = '' THEN
              WriteCellValue(Rec)
            ELSE
              WriteCellFormula(Rec);

         //ADC1.00 Change the "Row No." back
         "Row No." := "Row No." + RowOffSet;

        UNTIL NEXT = 0;

      IF ReportHeader <> '' THEN
        XlWrkShtWriter.AddHeader(
          TRUE,
          STRSUBSTNO('%1%2%1%3%4',GetExcelReference(1),ReportHeader,CRLF,CompanyName));

      XlWrkShtWriter.AddHeader(
        FALSE,
        STRSUBSTNO(Text006,GetExcelReference(2),GetExcelReference(3),CRLF,UserID2));

      IF UseInfoSheet THEN BEGIN
        IF InfoExcelBuf.FINDSET THEN BEGIN
          XlWrkShtWriter := XlWrkBkWriter.AddWorksheet(Text023);
          REPEAT
            InfoRecNo := InfoRecNo + 1;
            IF NOT UpdateProgressDialog(ExcelBufferDialogMgt,LastUpdate,RecNo + InfoRecNo,TotalRecNo) THEN BEGIN
              QuitExcel;
              ERROR(Text035)
            END;
            IF InfoExcelBuf.Formula = '' THEN
              WriteCellValue(InfoExcelBuf)
            ELSE
              WriteCellFormula(InfoExcelBuf)
          UNTIL InfoExcelBuf.NEXT = 0;
        END;
      END;

      ExcelBufferDialogMgt.Close;
    END;

    LOCAL PROCEDURE WriteCellValue@28(ExcelBuffer@1000 : Record 370);
    VAR
      Decorator@1001 : DotNet "'Microsoft.Dynamics.Nav.OpenXml, Version=7.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.Microsoft.Dynamics.Nav.OpenXml.Spreadsheet.CellDecorator";
    BEGIN
      WITH ExcelBuffer DO BEGIN
        GetCellDecorator(Bold,Italic,Underline,Decorator);

        CASE "Cell Type" OF
          "Cell Type"::Number:
            XlWrkShtWriter.SetCellValueNumber("Row No.",xlColID,"Cell Value as Text",NumberFormat,Decorator);
          "Cell Type"::Text:
            XlWrkShtWriter.SetCellValueText("Row No.",xlColID,"Cell Value as Text",Decorator);
          "Cell Type"::Date:
            XlWrkShtWriter.SetCellValueDate("Row No.",xlColID,"Cell Value as Text",NumberFormat,Decorator);
          "Cell Type"::Time:
            XlWrkShtWriter.SetCellValueTime("Row No.",xlColID,"Cell Value as Text",NumberFormat,Decorator);
          ELSE
            ERROR(Text039)
        END;
      END;
    END;

    LOCAL PROCEDURE WriteCellFormula@38(ExcelBuffer@1000 : Record 370);
    VAR
      Decorator@1001 : DotNet "'Microsoft.Dynamics.Nav.OpenXml, Version=7.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.Microsoft.Dynamics.Nav.OpenXml.Spreadsheet.CellDecorator";
    BEGIN
      WITH ExcelBuffer DO BEGIN
        GetCellDecorator(Bold,Italic,Underline,Decorator);

        XlWrkShtWriter.SetCellFormula("Row No.",xlColID,GetFormula,NumberFormat,Decorator);
      END;
    END;

    LOCAL PROCEDURE GetCellDecorator@33(IsBold@1000 : Boolean;IsItalic@1001 : Boolean;IsUnderlined@1002 : Boolean;VAR Decorator@1003 : DotNet "'Microsoft.Dynamics.Nav.OpenXml, Version=7.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.Microsoft.Dynamics.Nav.OpenXml.Spreadsheet.CellDecorator");
    BEGIN
      IF IsBold AND IsItalic AND IsUnderlined THEN BEGIN
        Decorator := XlWrkShtWriter.DefaultBoldItalicUnderlinedCellDecorator;
        EXIT;
      END;

      IF IsBold AND IsItalic THEN BEGIN
        Decorator := XlWrkShtWriter.DefaultBoldItalicCellDecorator;
        EXIT;
      END;

      IF IsBold AND IsUnderlined THEN BEGIN
        Decorator := XlWrkShtWriter.DefaultBoldUnderlinedCellDecorator;
        EXIT;
      END;

      IF IsBold THEN BEGIN
        Decorator := XlWrkShtWriter.DefaultBoldCellDecorator;
        EXIT;
      END;

      IF IsItalic AND IsUnderlined THEN BEGIN
        Decorator := XlWrkShtWriter.DefaultItalicUnderlinedCellDecorator;
        EXIT;
      END;

      IF IsItalic THEN BEGIN
        Decorator := XlWrkShtWriter.DefaultItalicCellDecorator;
        EXIT;
      END;

      IF IsUnderlined THEN
        Decorator := XlWrkShtWriter.DefaultUnderlinedCellDecorator
      ELSE
        Decorator := XlWrkShtWriter.DefaultCellDecorator;
    END;

    PROCEDURE CreateRangeName@9(RangeName@1000 : Text[30];FromColumnNo@1001 : Integer;FromRowNo@1002 : Integer);
    VAR
      TempExcelBuf@1005 : TEMPORARY Record 370;
      ToxlRowID@1004 : Text[10];
    BEGIN
      SETCURRENTKEY("Row No.","Column No.");
      IF FIND('+') THEN
        ToxlRowID := xlRowID;
      TempExcelBuf.VALIDATE("Row No.",FromRowNo);
      TempExcelBuf.VALIDATE("Column No.",FromColumnNo);

      XlWrkShtWriter.AddRange(
        RangeName,
        GetExcelReference(4) + TempExcelBuf.xlColID + GetExcelReference(4) + TempExcelBuf.xlRowID +
        ':' +
        GetExcelReference(4) + TempExcelBuf.xlColID + GetExcelReference(4) + ToxlRowID);
    END;

    PROCEDURE GiveUserControl@3();
    BEGIN
      IF NOT ISNULL(XlApp) THEN BEGIN
        XlApp.Visible := TRUE;
        XlApp.UserControl := TRUE;
        CLEAR(XlApp);
      END;
    END;

    PROCEDURE ReadSheet@4();
    VAR
      ExcelBufferDialogMgt@1003 : Codeunit 5370;
      CellData@1002 : DotNet "'Microsoft.Dynamics.Nav.OpenXml, Version=7.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.Microsoft.Dynamics.Nav.OpenXml.Spreadsheet.CellData";
      Enumerator@1001 : DotNet "'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Collections.IEnumerator";
      i@1000 : Integer;
      RowCount@1009 : Integer;
      LastUpdate@1004 : DateTime;
    BEGIN
      LastUpdate := CURRENTDATETIME;
      ExcelBufferDialogMgt.Open(Text007);
      DELETEALL;

      Enumerator := XlWrkShtReader.GetEnumerator;
      RowCount := XlWrkShtReader.RowCount;
      WHILE Enumerator.MoveNext DO BEGIN
        CellData := Enumerator.Current;
        IF CellData.HasValue THEN BEGIN
          VALIDATE("Row No.",CellData.RowNumber);
          VALIDATE("Column No.",CellData.ColumnNumber);
          ParseCellValue(CellData.Value,CellData.Format);
          INSERT;
        END;

        i := i + 1;
        COMMIT;
        IF NOT UpdateProgressDialog(ExcelBufferDialogMgt,LastUpdate,i,RowCount) THEN BEGIN
          QuitExcel;
          ERROR(Text035)
        END;
      END;

      QuitExcel;
      ExcelBufferDialogMgt.Close;
    END;

    LOCAL PROCEDURE ParseCellValue@40(Value@1000 : Text;FormatString@1001 : Text);
    VAR
      DateTime@1002 : DateTime;
      Decimal@1004 : Decimal;
    BEGIN
      // The format contains only en-US number separators, this is an OpenXML standard requirement
      // The algorithm sieves the data based on formatting as follows (the steps must run in this order)
      // 1. FormatString = '@' -> Text
      // 2. FormatString.Contains(':') -> Time
      // 3. FormatString.ContainsOneOf('y', 'm', 'd') && FormatString.DoesNotContain('Red') -> Date
      // 4. anything else -> Decimal

      NumberFormat := COPYSTR(FormatString,1,30);

      IF FormatString = '@' THEN BEGIN
        "Cell Type" := "Cell Type"::Text;
        "Cell Value as Text" := Value;
        EXIT;
      END;

      EVALUATE(Decimal,Value);

      IF STRPOS(FormatString,':') <> 0 THEN BEGIN
        // Excel Time is stored in OADate format
        "Cell Type" := "Cell Type"::Time;
        "Cell Value as Text" := ConvertDateTimeDecimalToStringInLocalTime(Decimal);
        EXIT;
      END;

      IF ((STRPOS(FormatString,'y') <> 0) OR
          (STRPOS(FormatString,'m') <> 0) OR
          (STRPOS(FormatString,'d') <> 0)) AND
         (STRPOS(FormatString,'Red') = 0)
      THEN BEGIN
        // Excel Date is stored in OATime format
        // Decimal integral component is number of days since 30-12-1899
        // See: http://msdn.microsoft.com/en-us/library/system.datetime.tooadate.aspx
        // FromOADate can't be used because it is utc dependent
        DateTime := CREATEDATETIME(DMY2DATE(30,12,1899) + ROUND(Decimal),0T);
        "Cell Type" := "Cell Type"::Date;
        "Cell Value as Text" := FORMAT(DT2DATE(DateTime));
        EXIT;
      END;

      "Cell Type" := "Cell Type"::Number;
      "Cell Value as Text" := FORMAT(ROUND(Decimal,0.000001),0,1);
    END;

    PROCEDURE SelectSheetsName@6(FileName@1000 : Text) : Text[250];
    VAR
      SheetNames@1008 : DotNet "'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Collections.ArrayList";
      SheetName@1002 : Text[250];
      SelectedSheetName@1007 : Text[250];
      SheetsList@1004 : Text[250];
      EndOfLoop@1003 : Integer;
      i@1001 : Integer;
      OptionNo@1005 : Integer;
    BEGIN
      IF FileName = '' THEN
        ERROR(Text001);

      XlWrkBkReader := XlWrkBkReader.Open(FileName);

      SheetNames := SheetNames.ArrayList(XlWrkBkReader.SheetNames);
      IF NOT ISNULL(SheetNames) THEN BEGIN
        i := 0;
        EndOfLoop := SheetNames.Count - 1;
        WHILE i <= EndOfLoop DO BEGIN
          SheetName := SheetNames.Item(i);
          IF (SheetName <> '') AND (STRLEN(SheetsList) + STRLEN(SheetName) < 250) THEN
            SheetsList := SheetsList + SheetName + ','
          ELSE
            i := EndOfLoop;
          i := i + 1;
        END;
        IF i > 1 THEN BEGIN
          IF SheetsList <> '' THEN BEGIN
            OptionNo := STRMENU(SheetsList,1,SelectWorksheetMsg);
            IF OptionNo <> 0 THEN
              SelectedSheetName := SELECTSTR(OptionNo,SheetsList);
          END
        END ELSE
          SelectedSheetName := SheetName;
      END;

      QuitExcel;
      EXIT(SelectedSheetName);
    END;

    PROCEDURE GetExcelReference@10(Which@1000 : Integer) : Text[250];
    BEGIN
      CASE Which OF
        1:
          EXIT(Text013);
        // DO NOT TRANSLATE: &B is the Excel code to turn bold printing on or off for customized Header/Footer.
        2:
          EXIT(Text014);
        // DO NOT TRANSLATE: &D is the Excel code to print the current date in customized Header/Footer.
        3:
          EXIT(Text015);
        // DO NOT TRANSLATE: &P is the Excel code to print the page number in customized Header/Footer.
        4:
          EXIT('$');
        // DO NOT TRANSLATE: $ is the Excel code for absolute reference to cells.
        5:
          EXIT(Text016);
        // DO NOT TRANSLATE: A1 is the Excel reference of the first cell.
        6:
          EXIT(Text017);
        // DO NOT TRANSLATE: SUMIF is the name of the Excel function used to summarize values according to some conditions.
        7:
          EXIT(Text018);
        // DO NOT TRANSLATE: The #N/A Excel error value occurs when a value is not available to a function or formula.
        8:
          EXIT(Text019);
        // DO NOT TRANSLATE: GLAcc is used to define an Excel range name. You must refer to Excel rules to change this term.
        9:
          EXIT(Text020);
        // DO NOT TRANSLATE: Period is used to define an Excel range name. You must refer to Excel rules to change this term.
        10:
          EXIT(Text021);
        // DO NOT TRANSLATE: Budget is used to define an Excel worksheet name. You must refer to Excel rules to change this term.
        11:
          EXIT(Text022);
        // DO NOT TRANSLATE: CostAcc is used to define an Excel range name. You must refer to Excel rules to change this term.
      END;
    END;

    PROCEDURE ExportBudgetFilterToFormula@11(VAR ExcelBuf@1000 : Record 370) : Boolean;
    VAR
      ExcelBufFormula@1001 : TEMPORARY Record 370;
      FirstRow@1002 : Integer;
      LastRow@1003 : Integer;
      HasFormulaError@1005 : Boolean;
      ThisCellHasFormulaError@1006 : Boolean;
      ExcelBufFormula2@1004 : TEMPORARY Record 370;
    BEGIN
      ExcelBuf.SETFILTER(Formula,'<>%1','');
      IF ExcelBuf.FINDSET THEN
        REPEAT
          ExcelBufFormula := ExcelBuf;
          ExcelBufFormula.INSERT;
        UNTIL ExcelBuf.NEXT = 0;
      ExcelBuf.RESET;

      WITH ExcelBufFormula DO
        IF FINDSET THEN
          REPEAT
            ThisCellHasFormulaError := FALSE;
            ExcelBuf.SETRANGE("Column No.",1);
            ExcelBuf.SETFILTER("Row No.",'<>%1',"Row No.");
            ExcelBuf.SETFILTER("Cell Value as Text",Formula);
            ExcelBufFormula2 := ExcelBufFormula;
            IF ExcelBuf.FINDSET THEN
              REPEAT
                IF NOT GET(ExcelBuf."Row No.","Column No.") THEN
                  ExcelBuf.MARK(TRUE);
              UNTIL ExcelBuf.NEXT = 0;
            ExcelBufFormula := ExcelBufFormula2;
            ClearFormula;
            ExcelBuf.SETRANGE("Cell Value as Text");
            ExcelBuf.SETRANGE("Row No.");
            IF ExcelBuf.FINDSET THEN
              REPEAT
                IF ExcelBuf.MARK THEN BEGIN
                  LastRow := ExcelBuf."Row No.";
                  IF FirstRow = 0 THEN
                    FirstRow := LastRow;
                END ELSE
                  IF FirstRow <> 0 THEN BEGIN
                    IF FirstRow = LastRow THEN
                      ThisCellHasFormulaError := AddToFormula(xlColID + FORMAT(FirstRow))
                    ELSE
                      ThisCellHasFormulaError :=
                        AddToFormula('SUM(' + xlColID + FORMAT(FirstRow) + ':' + xlColID + FORMAT(LastRow) + ')');
                    FirstRow := 0;
                    IF ThisCellHasFormulaError THEN
                      SetFormula(ExcelBuf.GetExcelReference(7));
                  END;
              UNTIL ThisCellHasFormulaError OR (ExcelBuf.NEXT = 0);

            IF NOT ThisCellHasFormulaError AND (FirstRow <> 0) THEN BEGIN
              IF FirstRow = LastRow THEN
                ThisCellHasFormulaError := AddToFormula(xlColID + FORMAT(FirstRow))
              ELSE
                ThisCellHasFormulaError :=
                  AddToFormula('SUM(' + xlColID + FORMAT(FirstRow) + ':' + xlColID + FORMAT(LastRow) + ')');
              FirstRow := 0;
              IF ThisCellHasFormulaError THEN
                SetFormula(ExcelBuf.GetExcelReference(7));
            END;

            ExcelBuf.RESET;
            ExcelBuf.GET("Row No.","Column No.");
            ExcelBuf.SetFormula(GetFormula);
            ExcelBuf.MODIFY;
            HasFormulaError := HasFormulaError OR ThisCellHasFormulaError;
          UNTIL NEXT = 0;

      EXIT(HasFormulaError);
    END;

    PROCEDURE AddToFormula@12(Text@1001 : Text[30]) : Boolean;
    VAR
      Overflow@1002 : Boolean;
      LongFormula@1000 : Text[1000];
    BEGIN
      LongFormula := GetFormula;
      IF LongFormula = '' THEN
        LongFormula := '=';
      IF LongFormula <> '=' THEN
        IF STRLEN(LongFormula) + 1 > MAXSTRLEN(LongFormula) THEN
          Overflow := TRUE
        ELSE
          LongFormula := LongFormula + '+';
      IF STRLEN(LongFormula) + STRLEN(Text) > MAXSTRLEN(LongFormula) THEN
        Overflow := TRUE
      ELSE
        SetFormula(LongFormula + Text);
      EXIT(Overflow);
    END;

    PROCEDURE GetFormula@13() : Text[1000];
    BEGIN
      EXIT(Formula + Formula2 + Formula3 + Formula4);
    END;

    PROCEDURE SetFormula@22(LongFormula@1000 : Text[1000]);
    BEGIN
      ClearFormula;
      IF LongFormula = '' THEN
        EXIT;

      Formula := COPYSTR(LongFormula,1,MAXSTRLEN(Formula));
      IF STRLEN(LongFormula) > MAXSTRLEN(Formula) THEN
        Formula2 := COPYSTR(LongFormula,MAXSTRLEN(Formula) + 1,MAXSTRLEN(Formula2));
      IF STRLEN(LongFormula) > MAXSTRLEN(Formula) + MAXSTRLEN(Formula2) THEN
        Formula3 := COPYSTR(LongFormula,MAXSTRLEN(Formula) + MAXSTRLEN(Formula2) + 1,MAXSTRLEN(Formula3));
      IF STRLEN(LongFormula) > MAXSTRLEN(Formula) + MAXSTRLEN(Formula2) + MAXSTRLEN(Formula3) THEN
        Formula4 := COPYSTR(LongFormula,MAXSTRLEN(Formula) + MAXSTRLEN(Formula2) + MAXSTRLEN(Formula3) + 1,MAXSTRLEN(Formula4));
    END;

    PROCEDURE ClearFormula@18();
    BEGIN
      Formula := '';
      Formula2 := '';
      Formula3 := '';
      Formula4 := '';
    END;

    PROCEDURE NewRow@14();
    BEGIN
      CurrentRow := CurrentRow + 1;
      CurrentCol := 0;
    END;

    PROCEDURE AddColumn@16(Value@1000 : Variant;IsFormula@1001 : Boolean;CommentText@1002 : Text[1000];IsBold@1003 : Boolean;IsItalics@1004 : Boolean;IsUnderline@1005 : Boolean;NumFormat@1006 : Text[30];CellType@1007 : Option);
    BEGIN
      IF CurrentRow < 1 THEN
        NewRow;

      CurrentCol := CurrentCol + 1;
      INIT;
      VALIDATE("Row No.",CurrentRow);
      VALIDATE("Column No.",CurrentCol);
      IF IsFormula THEN
        SetFormula(FORMAT(Value))
      ELSE
        "Cell Value as Text" := FORMAT(Value);
      Comment := CommentText;
      Bold := IsBold;
      Italic := IsItalics;
      Underline := IsUnderline;
      NumberFormat := NumFormat;
      "Cell Type" := CellType;
      INSERT;
    END;

    PROCEDURE StartRange@19();
    VAR
      TempExcelBuf@1000 : TEMPORARY Record 370;
    BEGIN
      TempExcelBuf.VALIDATE("Row No.",CurrentRow);
      TempExcelBuf.VALIDATE("Column No.",CurrentCol);

      RangeStartXlRow := TempExcelBuf.xlRowID;
      RangeStartXlCol := TempExcelBuf.xlColID;
    END;

    PROCEDURE EndRange@23();
    VAR
      TempExcelBuf@1000 : TEMPORARY Record 370;
    BEGIN
      TempExcelBuf.VALIDATE("Row No.",CurrentRow);
      TempExcelBuf.VALIDATE("Column No.",CurrentCol);

      RangeEndXlRow := TempExcelBuf.xlRowID;
      RangeEndXlCol := TempExcelBuf.xlColID;
    END;

    PROCEDURE CreateRange@45(RangeName@1000 : Text[250]) : Boolean;
    BEGIN
      XlWrkShtWriter.AddRange(
        RangeName,
        GetExcelReference(4) + RangeStartXlCol + GetExcelReference(4) + RangeStartXlRow +
        ':' +
        GetExcelReference(4) + RangeEndXlCol + GetExcelReference(4) + RangeEndXlRow);
    END;

    PROCEDURE AutoFit@20(RangeName@1000 : Text[50]);
    BEGIN
      IF NOT ISNULL(XlWrkBk) THEN
        XlHelper.AutoFitRangeColumns(XlWrkBk,ActiveSheetName,RangeName);
    END;

    PROCEDURE BorderAround@39(RangeName@1000 : Text[50]);
    BEGIN
      IF NOT ISNULL(XlWrkBk) THEN
        XlHelper.BorderAroundRange(XlWrkBk,ActiveSheetName,RangeName,1);
    END;

    PROCEDURE ClearNewRow@26();
    BEGIN
      CurrentRow := 0;
      CurrentCol := 0;
    END;

    PROCEDURE SetUseInfoSheet@25();
    BEGIN
      UseInfoSheet := TRUE;
    END;

    PROCEDURE AddInfoColumn@24(Value@1006 : Variant;IsFormula@1005 : Boolean;CommentText@1004 : Text[1000];IsBold@1003 : Boolean;IsItalics@1002 : Boolean;IsUnderline@1001 : Boolean;NumFormat@1000 : Text[30];CellType@1007 : Option);
    BEGIN
      IF CurrentRow < 1 THEN
        NewRow;

      CurrentCol := CurrentCol + 1;
      INIT;
      InfoExcelBuf.VALIDATE("Row No.",CurrentRow);
      InfoExcelBuf.VALIDATE("Column No.",CurrentCol);
      IF IsFormula THEN
        InfoExcelBuf.SetFormula(FORMAT(Value))
      ELSE
        InfoExcelBuf."Cell Value as Text" := FORMAT(Value);
      InfoExcelBuf.Bold := IsBold;
      InfoExcelBuf.Italic := IsItalics;
      InfoExcelBuf.Underline := IsUnderline;
      InfoExcelBuf.NumberFormat := NumFormat;
      InfoExcelBuf."Cell Type" := CellType;
      InfoExcelBuf.INSERT;
    END;

    PROCEDURE UTgetGlobalValue@35(globalVariable@1001 : Text[30];VAR value@1000 : Variant);
    BEGIN
      CASE globalVariable OF
        'CurrentRow':
          value := CurrentRow;
        'CurrentCol':
          value := CurrentCol;
        'RangeStartXlRow':
          value := RangeStartXlRow;
        'RangeStartXlCol':
          value := RangeStartXlCol;
        'RangeEndXlRow':
          value := RangeEndXlRow;
        'RangeEndXlCol':
          value := RangeEndXlCol;
        'XlWrkSht':
          value := XlWrkShtWriter;
        'ExcelFile':
          value := FileNameServer;
        ELSE
          ERROR(Text038,globalVariable);
      END;
    END;

    PROCEDURE SetCurrent@27(NewCurrentRow@1000 : Integer;NewCurrentCol@1001 : Integer);
    BEGIN
      CurrentRow := NewCurrentRow;
      CurrentCol := NewCurrentCol;
    END;

    PROCEDURE CreateValidationRule@17(Range@1000 : Code[20]);
    BEGIN
      XlWrkShtWriter.AddRangeDataValidation(
        Range,
        GetExcelReference(4) + RangeStartXlCol + GetExcelReference(4) + RangeStartXlRow +
        ':' +
        GetExcelReference(4) + RangeEndXlCol + GetExcelReference(4) + RangeEndXlRow);
    END;

    PROCEDURE QuitExcel@29();
    BEGIN
      // Close and clear the OpenXml book
      CloseBook;

      // Clear the worksheet automation
      IF NOT ISNULL(XlWrkSht) THEN
        CLEAR(XlWrkSht);

      // Clear the workbook automation
      IF NOT ISNULL(XlWrkBk) THEN
        CLEAR(XlWrkBk);

      // Clear and quit the Excel application automation
      IF NOT ISNULL(XlApp) THEN BEGIN
        XlHelper.CallQuit(XlApp);
        CLEAR(XlApp);
      END;
    END;

    PROCEDURE OpenExcel@31();
    VAR
      FileNameClient@1000 : Text;
    BEGIN
      IF OpenUsingDocumentService('') THEN
        EXIT;

      IF NOT PreOpenExcel THEN
        EXIT;

      // rename the Temporary filename into a more UI friendly name in a new subdirectory
      FileNameClient := FileManagement.DownloadTempFile(FileNameServer);
      FileNameClient := FileManagement.MoveAndRenameClientFile(FileNameClient,GetFriendlyFilename,FORMAT(CREATEGUID));

      XlWrkBk := XlHelper.CallOpen(XlApp,FileNameClient);

      PostOpenExcel;
    END;

    PROCEDURE DownloadAndOpenExcel@34();
    VAR
      ClientFilename@1000 : Text;
    BEGIN
      ClientFilename := GetFriendlyFilename;

      IF FileManagement.CanRunDotNetOnClient THEN BEGIN
        ClientFilename := FileManagement.SaveFileDialog('Save file','',Text034);
        IF ClientFilename = '' THEN
          EXIT;
        IF FileManagement.GetExtension(ClientFilename) = '' THEN
          ClientFilename += ExcelFileExtensionTok;
      END;

      OverwriteAndOpenExistingExcel(ClientFilename);
    END;

    PROCEDURE OverwriteAndOpenExistingExcel@15(FileName@1000 : Text);
    BEGIN
      IF FileName = '' THEN
        ERROR(Text001);

      IF OpenUsingDocumentService(FileName) THEN
        EXIT;

      IF NOT PreOpenExcel THEN
        EXIT;

      FileManagement.DownloadToFile(FileNameServer,FileName);
      XlWrkBk := XlHelper.CallOpen(XlApp,FileName);

      PostOpenExcel;
    END;

    LOCAL PROCEDURE OpenUsingDocumentService@21(FileName@1000 : Text) : Boolean;
    VAR
      DocumentServiceMgt@1005 : Codeunit 9510;
      FileMgt@1004 : Codeunit 419;
      PathHelper@1003 : DotNet "'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.IO.Path";
      DialogWindow@1002 : Dialog;
      DocumentUrl@1001 : Text;
    BEGIN
      IF NOT EXISTS(FileNameServer) THEN
        ERROR(Text003,FileNameServer);

      // if document service is configured we save the generated document to SharePoint and open it from there.
      IF DocumentServiceMgt.IsConfigured THEN BEGIN
        IF FileName = '' THEN
          FileName := 'Book.' + PathHelper.ChangeExtension(PathHelper.GetRandomFileName,'xlsx')
        ELSE BEGIN
          // if file is not applicable for the service it can not be opened using the document service.
          IF NOT DocumentServiceMgt.IsServiceUri(FileName) THEN
            EXIT(FALSE);

          FileName := FileMgt.GetFileName(FileName);
        END;

        DialogWindow.OPEN(STRSUBSTNO(SavingDocumentMsg,FileName));
        DocumentUrl := DocumentServiceMgt.SaveFile(FileNameServer,FileName,TRUE);
        DocumentServiceMgt.OpenDocument(DocumentUrl);
        DialogWindow.CLOSE;
        EXIT(TRUE);
      END;

      EXIT(FALSE);
    END;

    LOCAL PROCEDURE PreOpenExcel@7() : Boolean;
    BEGIN
      IF NOT EXISTS(FileNameServer) THEN
        ERROR(Text003,FileNameServer);

      // Download file, if none RTC it should return a filename, and use client automation instead.
      IF NOT FileManagement.CanRunDotNetOnClient THEN BEGIN
        IF NOT FileManagement.DownloadHandler(FileNameServer,Text040,'',Text034,GetFriendlyFilename) THEN
          ERROR(Text001);
        EXIT(FALSE);
      END;

      XlApp := XlApp.ApplicationClass;
      IF ISNULL(XlApp) THEN
        ERROR(Text000);

      EXIT(TRUE);
    END;

    LOCAL PROCEDURE PostOpenExcel@8();
    BEGIN
      XlWrkBk := XlApp.ActiveWorkbook;

      IF ISNULL(XlWrkBk) THEN
        ERROR(Text036);

      // autofit all columns on all worksheets
      XlHelper.AutoFitColumnsInAllWorksheets(XlWrkBk);

      // activate the previous saved sheet name in the workbook
      XlHelper.ActivateSheet(XlWrkBk,ActiveSheetName);
    END;

    PROCEDURE CreateBookAndOpenExcel@32(SheetName@1000 : Text[250];ReportHeader@1003 : Text[80];CompanyName@1002 : Text[30];UserID2@1001 : Text);
    BEGIN
      CreateBook(SheetName);
      WriteSheet(ReportHeader,CompanyName,UserID2);
      CloseBook;
      OpenExcel;
      GiveUserControl;
    END;

    LOCAL PROCEDURE UpdateProgressDialog@36(VAR ExcelBufferDialogManagement@1000 : Codeunit 5370;VAR LastUpdate@1001 : DateTime;CurrentCount@1002 : Integer;TotalCount@1004 : Integer) : Boolean;
    VAR
      CurrentTime@1003 : DateTime;
    BEGIN
      // Refresh at 100%, and every second in between 0% to 100%
      // Duration is measured in miliseconds -> 1 sec = 1000 ms
      CurrentTime := CURRENTDATETIME;
      IF (CurrentCount = TotalCount) OR (CurrentTime - LastUpdate >= 1000) THEN BEGIN
        LastUpdate := CurrentTime;
        ExcelBufferDialogManagement.SetProgress(ROUND(CurrentCount / TotalCount * 10000,1));
        IF NOT ExcelBufferDialogManagement.RUN THEN
          EXIT(FALSE);
      END;

      EXIT(TRUE)
    END;

    LOCAL PROCEDURE GetFriendlyFilename@46() : Text;
    BEGIN
      IF FriendlyName = '' THEN
        EXIT('Book1' + ExcelFileExtensionTok);

      EXIT(FileManagement.StripNotsupportChrInFileName(FriendlyName) + ExcelFileExtensionTok);
    END;

    PROCEDURE SetFriendlyFilename@41(Name@1000 : Text);
    BEGIN
      FriendlyName := Name;
    END;

    PROCEDURE ConvertDateTimeDecimalToStringInLocalTime@47(DateTimeAsOADate@1000 : Decimal) : Text[250];
    VAR
      DotNetDateTime@1003 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.DateTime";
      DotNetDateTimeWithKind@1002 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.DateTime";
      DotNetDateTimeKind@1001 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.DateTimeKind";
      DateTime@1004 : DateTime;
    BEGIN
      DotNetDateTime := DotNetDateTime.FromOADate(DateTimeAsOADate);
      DotNetDateTimeWithKind := DotNetDateTime.DateTime(DotNetDateTime.Ticks,DotNetDateTimeKind.Local);
      DateTime := DotNetDateTimeWithKind;
      EXIT(FORMAT(DT2TIME(DateTime)));
    END;

    PROCEDURE ValidateSheetName@1000000007(SheetName@1000000000 : Text[250]) : Text[30];
    VAR
      NewSheetName@1000000001 : Text[30];
    BEGIN
      //ADC1.00
      IF SheetName = '' THEN
        EXIT(SheetName);

      //Remove Bad Characters
      SheetName := DELCHR(SheetName,'=',SheetBadChars);
      //Strip Leading or Trailing Spaces
      SheetName := DELCHR(SheetName,'<>');
      //Check the Length of the Sheet Name
      IF STRLEN(SheetName) > 30 THEN
        SheetName := FORMAT(SheetName,30);

      EXIT(SheetName);
    END;

    LOCAL PROCEDURE AddNewWorksheet@1000000000();
    VAR
      NewSheetName@1000000000 : Text[30];
    BEGIN
      //ADC1.00
      //Is this a new worksheet?
      IF ("Column No." = 0) AND ("Cell Value as Text" <> '') THEN BEGIN
        //Create a New Worksheet Name
        NewSheetName := ValidateSheetName("Cell Value as Text");
        //Compare to the Active Sheet Name
        IF NewSheetName <> ActiveSheetName THEN BEGIN
          //Set the ActiveSheetName
          ActiveSheetName := NewSheetName;
          //Set the RowOffSet
          RowOffSet := "Row No." - 1;
          //Add the new Worksheet
          XlWrkShtWriter := XlWrkBkWriter.AddWorksheet(ActiveSheetName);
        END;
      END;
    END;

    PROCEDURE GetCellID@1000000003(ColNo@1000000001 : Integer;RowNo@1000000002 : Integer) : Text;
    VAR
      TempExcelBuf@1000000000 : TEMPORARY Record 370;
    BEGIN
      //ADC1.00
      //Set the xlColID from Numeric to Alpha (A)
      TempExcelBuf.VALIDATE("Column No.",ColNo);
      //Set the xlRowID from Numeric to Text  (1)
      TempExcelBuf.VALIDATE("Row No.",RowNo);

      //Return the Cell ID as a Text String (A1)
      EXIT(TempExcelBuf.xlColID+TempExcelBuf.xlRowID);
    END;

    BEGIN
    {
      ADC1.00 Added Functions ValidateSheetName, NewWorksheet, GetCellID
      ADC1.00 Added Variable RowOffSet integer
      ADC1.00 Added Commented Code
    }
    END.
  }
}

